/*
** vgetca.c
**
** Pictor, Version 1.51, Copyright (c) 1992-94 SoftCircuits
** Redistributed by permission.
*/

#include "pictor.h"

/*
** Returns the character/attribute from the current video position.
*/
int vgetca(void)
{
	int retval;
	/* wcc needs slightly different _asm constructs to properly handle inline labels- W. Jones. */
#ifdef __WATCOMC__
	_asm{
			push	ds
			mov	si,_PL_offset
			cmp	_PL_snowcheck,FALSE
			mov	ax,_PL_segment
			mov	ds,ax
			je 	direct
			mov	dx,CGA_STATUS_PORT
		scan_lo:
			in 	al,dx
			shr	al,1
			jc 	scan_lo
			cli
		scan_hi:
			in 	al,dx
			shr	al,1
			jnc	scan_hi
			lodsw
			sti
			jmp	end_vgetca
		direct:
			lodsw
		end_vgetca:
			pop	ds
			mov	_PL_offset,si
			mov	retval,ax
	}

#else
	_asm	push	ds
	_asm	mov	si,_PL_offset
	_asm	cmp	_PL_snowcheck,FALSE
	_asm	mov	ax,_PL_segment
	_asm	mov	ds,ax
	_asm	je 	direct
	_asm	mov	dx,CGA_STATUS_PORT
	scan_lo:
	_asm	in 	al,dx
	_asm	shr	al,1
	_asm	jc 	scan_lo
	_asm	cli
	scan_hi:
	_asm	in 	al,dx
	_asm	shr	al,1
	_asm	jnc	scan_hi
	_asm	lodsw
	_asm	sti
	_asm	jmp	end_vgetca
	direct:
	_asm	lodsw
	end_vgetca:
	_asm	pop	ds
	_asm	mov	_PL_offset,si
	_asm	mov	retval,ax
#endif

	return(retval);

} /* vgetca */
